package com.example.demo3.bean.util;

import java.sql.Connection;
import java.sql.DriverManager;

public class DBConnection {
    private String FileName;
    private int DBType;
    private Connection conn;
    private String MySqlDRIVER;
    private String MySqlURL;
    private DBConnection() {
        conn = null;
    }
    public Connection getConn() {
        DBType=1;
        switch (DBType) {
            case 1:
                return (getConnToMysql());
                default:
                    return null;
        }
    }
    private Connection getConnToMysql() {
        try {
            MySqlDRIVER = "com.mysql.jdbc.Driver";
            MySqlURL = "jdbc:mysql://localhost:3306/demo3?"
            +"user=root&password=mysql123456"+
            "useUnicode=true&characterEncoding=utf8";
            Class.forName(MySqlDRIVER);
            conn = DriverManager.getConnection(MySqlURL);
        } catch (Exception e) {
            return null;
        }
        return null;
    }
}
